﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefPerson" :model="statePerson.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_PersonCode_FormItem" prop="Entity.PersonCode" :label="$t('message.autotrans._Model_Person_PersonCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Person_PersonCode')}), trigger: 'blur' }]" >
            <el-input v-model="statePerson.vmModel.Entity.PersonCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_PersonName_FormItem" prop="Entity.PersonName" :label="$t('message.autotrans._Model_Person_PersonName')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Person_PersonName')}), trigger: 'blur' }]" >
            <el-input v-model="statePerson.vmModel.Entity.PersonName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_Gender_FormItem" prop="Entity.Gender" :label="$t('message.autotrans._Model_Person_Gender')">
            <el-select v-model="statePerson.vmModel.Entity.Gender" clearable>
               <el-option key="MALE" value="MALE" :label="$t('message.autotrans._Enum_PersonGender_MALE')"></el-option>
               <el-option key="FEMALE" value="FEMALE" :label="$t('message.autotrans._Enum_PersonGender_FEMALE')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_LineCodeId_FormItem" prop="Entity.LineCodeId" :label="$t('message.autotrans._Model_Person_LineCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Person_LineCode')}), trigger: 'blur' }]" >
            <el-select v-model="statePerson.vmModel.Entity.LineCodeId" @change="OnLineg6607370258Change" filterable clearable>
               <el-option v-for="item in statePerson.g3f51d11b936345559bc2b77073b36142AllLines" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_StationCodeId_FormItem" prop="Entity.StationCodeId" :label=" $t('message.autotrans.Page工位编码')">
            <el-select v-model="statePerson.vmModel.Entity.StationCodeId" filterable clearable>
               <el-option v-for="item in statePerson.AllStationCodes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_PhoneNumber_FormItem" prop="Entity.PhoneNumber" :label="$t('message.autotrans._Model_Person_PhoneNumber')">
            <el-input v-model="statePerson.vmModel.Entity.PhoneNumber" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_Address_FormItem" prop="Entity.Address" :label="$t('message.autotrans._Model_Person_Address')">
            <el-input v-model="statePerson.vmModel.Entity.Address" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Entity_EmpSkills_FormItem" prop="Entity.EmpSkills" :label="$t('message.autotrans._Model_Person_EmpSkills')">
            <el-input v-model="statePerson.vmModel.Entity.EmpSkills" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onSubmitPerson"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onClosePerson"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationPersonCreate;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { personApi } from '/@/api/baseinformation/person';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


const OnLineg6607370258Change= (row:any) => {
    
}

// 定义变量内容
const formRefPerson = ref();
const statePerson = reactive({
    vmModel: {
	  Entity:{
        PersonCode: '',
        PersonName: '',
        Gender: undefined,
        LineCodeId: null,
        StationCodeId: null,
        PhoneNumber: '',
        Address: '',
        EmpSkills: '',
      },

	},
    
    g3f51d11b936345559bc2b77073b36142AllLines : [] as any[],
    g3f51d11b936345559bc2b77073b36142SelectedLine  : [] as any[],
    AllLineCodes: [] as any[],
    AllStationCodes: [] as any[],
});

// 取消
const onClosePerson = () => {
    closeDialog();
};

// 提交
const onSubmitPerson = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefPerson.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            personApi().add(statePerson.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/BaseInformation/Operation/GetLines',[],false).then(x=>{statePerson.g3f51d11b936345559bc2b77073b36142AllLines = x});

    other.getSelectList('/api/BaseInformation/Person/GetLines',[],false).then(x=>{statePerson.AllLineCodes = x});
    other.getSelectList('/api/BaseInformation/Person/GetStations',[],false).then(x=>{statePerson.AllStationCodes = x});
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

